<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html lang="en">
<head>
<!-- 下拉框 -->
<link rel="stylesheet" href="/static/ace/css/chosen.css" />
<!-- jsp文件头和头部 -->
<%@ include file="../index/top.jsp"%>
</head>
<body class="no-skin">
	<!-- /section:basics/navbar.layout -->
	<div class="main-container" id="main-container">
		<!-- /section:basics/sidebar -->
		<div class="main-content">
			<div class="main-content-inner">
				<div class="page-content">
					<div class="row">
						<div class="col-xs-12 ">
							<form id="Form" method="post">
								<input type="hidden" name="id" id="id" value="${entity.id }" />
								<div id="zhongxin" style="padding-top: 13px;">
									<table id="table_report" class="table table-striped table-bordered table-hover">
										<tr>
											<td style="width: 79px; text-align: right; padding-top: 13px;">角色:</td>
											<td id="juese">
												<select class="chosen-select form-control notEmpty" name="roleId" id="roleId" data-placeholder="请选择角色" style="vertical-align: top;" style="width:98%;">
													<option value=""></option>
													<c:forEach items="${roleList}" var="role">
														<option value="${role.id }" <c:if test="${role.id == entity.roleId }">selected</c:if>>${role.roleName }</option>
													</c:forEach>
												</select>
											</td>
										</tr>
										<tr>
											<td style="width: 79px; text-align: right; padding-top: 13px;">登录账户:</td>
											<td>
												<input class="notEmpty" type="text" name="name" id="name" value="${entity.name }" maxlength="32" placeholder="这里输入用户名" title="用户名" style="width: 98%;" />
											</td>
										</tr>

										<tr>
											<td style="width: 79px; text-align: right; padding-top: 13px;">密码:</td>
											<td>
												<input type="password" id="ipt_password" maxlength="32" placeholder="输入密码" title="密码" style="width: 98%;" />
												<input type="hidden" name="password" id="hidden_password">
											</td>
										</tr>
										<tr>
											<td style="width: 79px; text-align: right; padding-top: 13px;">确认密码:</td>
											<td>
												<input type="password" id="ipt_check_password" maxlength="32" placeholder="确认密码" title="确认密码" style="width: 98%;" />
											</td>
										</tr>

										<tr>
											<td style="width: 79px; text-align: right; padding-top: 13px;">用户姓名:</td>
											<td>
												<input class="notEmpty" type="text" name="nickname" id="nickname" value="${entity.nickname }" maxlength="32" placeholder="这里输入姓名" title="姓名" style="width: 98%;" />
											</td>
										</tr>
										<tr>
											<td style="width: 79px; text-align: right; padding-top: 13px;">手机号:</td>
											<td>
												<input class="notEmpty" type="number" name="phone" id="phone" value="${entity.phone }" maxlength="32" placeholder="这里输入手机号" title="手机号" style="width: 98%;" />
											</td>
										</tr>

										<tr>
											<td style="width: 79px; text-align: right; padding-top: 13px;">备注:</td>
											<td>
												<input class="notEmpty" type="text" name="remarks" id="remarks" value="${entity.remarks }" placeholder="这里输入备注" maxlength="64" title="备注" style="width: 98%;" />
											</td>
										</tr>
										<tr>
											<td style="text-align: center;" colspan="10">
												<a class="btn btn-mini btn-primary" onclick="save();">保存</a>
												<a class="btn btn-mini btn-danger" onclick="top.Dialog.close();">取消</a>
											</td>
										</tr>
									</table>
								</div>
								<div id="zhongxin2" class="center" style="display: none">
									<br />
									<br />
									<br />
									<br />
									<img src="/static/images/jiazai.gif" />
									<br />
									<h4 class="lighter block green"></h4>
								</div>
							</form>
						</div>
						<!-- /.col -->
					</div>
					<!-- /.row -->
				</div>
				<!-- /.page-content -->
			</div>
		</div>
		<!-- /.main-content -->
	</div>
	<!-- /.main-container -->
	<!-- basic scripts -->
	<!-- 页面底部js¨ -->

	<!-- 页面底部js¨ -->
	<%@ include file="../../system/index/foot.jsp"%>
	<!-- 下拉框 -->
	<script src="/static/ace/js/chosen.jquery.js"></script>
	<script src="/static/ace/js/bootbox.js"></script>
	<!-- 日期框 -->
	<script src="/static/ace/js/date-time/bootstrap-datepicker.js"></script>
	<!--提示框-->
	<script type="text/javascript" src="/static/js/jquery.tips.js"></script>
	<script type="text/javascript" src="/static/js/common/common.js"></script>
	<script type="text/javascript" src="/static/js/common/commonTip.js"></script>
	<script type="text/javascript" src="/static/js/common/myValidation.js"></script>
	<script type="text/javascript" src="/static/js/jquery.md5.js"></script>
	<script type="text/javascript">
		$(top.hangge());
		//保存
		function save() {
			if (!myValidation.commonValid("Form")) {
				return false;
			}
			if ("${msg}" == "add") {
				if ($("#ipt_password").val().trim().length == 0) {
					bootbox.alert("请输入密码");
					return false;
				}
				if ($("#ipt_check_password").val().trim().length == 0) {
					bootbox.alert("请再次输入密码");
					return false;
				}
			}
			if ($("#ipt_password").val() != $("#ipt_check_password").val()) {
				bootbox.alert("密码需一致");
				return false;
			}
			$("#hidden_password").val($.md5($("#ipt_password").val()));

			$("#zhongxin").hide();
			$("#zhongxin2").show();
			$.post("/admin/user/${msg }", $("#Form").serialize(), function(result) {
				if (result.code == 200) {
					bootbox.alert("成功", function() {
						top.Dialog.close();
					});
				} else {
					bootbox.alert(result.mes);
				}
				$("#zhongxin").show();
				$("#zhongxin2").hide();
			})
		}

		$(function() {
			//日期框
			$('.date-picker').datepicker({
				autoclose : true,
				todayHighlight : true
			});
		});
	</script>
</body>
</html>